package Vista;
import javax.swing.*;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;


public class PantallaInicial{

	JFrame unFrame;
	JLabel unPanel;
	ImageIcon imagenPresentacion;
	
	public PantallaInicial(){
		armarPanel();
		inicializarFrame();
	}
	
	public void armarPanel(){
		unPanel = new JLabel();
		
		imagenPresentacion = new ImageIcon("imagenes/Presentacion.jpg");
		unPanel = new JLabel(imagenPresentacion);
		
		unPanel.addMouseListener(new AccionDelClick());
		unPanel.addMouseMotionListener(new AccionMovimientoMouse());
	}
	
	public void inicializarFrame(){
		unFrame = new JFrame();
		
		unFrame.setBackground(Color.black);
		unFrame.setSize(imagenPresentacion.getIconWidth()+2,imagenPresentacion.getIconHeight()+33);
		unFrame.setContentPane(unPanel);
		unFrame.addWindowListener(new MonitorVentanaBasica());
		
		unFrame.setResizable(false);
		unFrame.setTitle("Pooglins");
		unFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		Dimension pantallaResolucion = Toolkit.getDefaultToolkit().getScreenSize();
		
		int x =(int)Math.round(pantallaResolucion.getWidth()/2)-(int)Math.round(unFrame.getSize().getWidth()/2);
		int y =(int)Math.round(pantallaResolucion.getHeight()/2)-(int)Math.round(unFrame.getSize().getHeight()/2);
		unFrame.setLocation(x,y);
		unFrame.setVisible(true);
	}
	
	
	
	public static void main(String[] args){
		new PantallaInicial();
	}
	
	private class AccionMovimientoMouse extends MouseMotionAdapter{
		private Rectangle botonJugar;
		private Rectangle botonAyuda;
		
		public AccionMovimientoMouse(){
			botonJugar = new Rectangle(300,490,30,140);
			botonAyuda = new Rectangle(355,455,25,175);
		}
		
		public void mouseMoved(MouseEvent e){
			int xMouse = e.getY();
			int yMouse = e.getX();
			
			if ((botonJugar.contains(xMouse,yMouse)) || (botonAyuda.contains(xMouse,yMouse))){
				unPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
			}else{
				unPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
			}
			
		}
		
	}
	
	private class AccionDelClick extends MouseAdapter{
		private Rectangle botonJugar;
		private Rectangle botonAyuda;
		
		public AccionDelClick(){
			botonJugar = new Rectangle(300,490,30,140);
			botonAyuda = new Rectangle(355,455,25,175);
		}
		
		public void mouseClicked(MouseEvent e) {
			int xMouse = e.getY();
			int yMouse = e.getX();
			
			if (botonJugar.contains(xMouse,yMouse)){
				new MenuInicial();
				unFrame.setVisible(false);
			}else if (botonAyuda.contains(xMouse,yMouse)){
				new AyudaParaJugar(1);
				unFrame.setVisible(false);
			}
		}
	}
}